import Vue from 'vue'
import Router from 'vue-router'

import Layout from '@/layout'

Vue.use(Router)

//公共路由
export const constantRoutes  = [
	//首页
	{
		path: '/index',
		name:'首页',
		component: () => import('@/views/index'),
		hidden: true
	},
	{
		path: '/other',
		name:'测试页面',
		component: () => import('@/views/other'),
		hidden: true
	},
	{
		path: '/login',
		name:'登录',
		component: () => import('@/views/login'),
		hidden: true
	},
	{
		path: '/',
		name:'控制台',
		component: Layout,
		hidden: true,
		children:[{
			path: '/dashboard',
			name: '控制台',
			component: () => import('@/views/dashboard'),
			meta: {title:'控制台',icon:'#'}
		}]
	},
	{
		path: '/404',
		name:'404',
		component: () => import('@/views/404'),
		hidden: true
	}
]

//权限路由
export const asyncRoutes = []

const createRouter = () => new Router({
	mode:'history',
	routes: constantRoutes
})

//重置路由
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher 
}

const router = createRouter()

export default router